using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ZorbBall : MonoBehaviour
{
    [Header("References")]
    [SerializeField] Rigidbody rb;

    [Header("Attributes")]
    [SerializeField] float bounceForce;

    // Start is called before the first frame update
    void Start()
    {
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void OnCollisionEnter(Collision collision)
    {
        if(collision.gameObject.CompareTag("Person") || collision.gameObject.CompareTag("Player") || collision.gameObject.CompareTag("Wall"))
        {
            AudioManager.instance.PlaySFX(AudioManager.instance.bubbleHit);
            rb.velocity = Vector3.zero;
            rb.AddForce((collision.contacts[0].normal + Vector3.up).normalized * bounceForce, ForceMode.Impulse);
        }
        else if(collision.gameObject.CompareTag("Wall"))
        {
            AudioManager.instance.PlaySFX(AudioManager.instance.wallHit);
        }
    }
}
